{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="wap.php?app=home&act=index"><i class="return"></i></a>
	<div class="titleView-x">下单成功</div>
</div>

<div class="main-top cart-complete">
	<font>订单成功提交</font>
	<ul>
		<li><span>订单号</span><div>{$order_sn}</div></li>
		<li><span>订单金额</span><div class="r">￥{$total_price}</div></li>
		<li><span>支付方式</span><div>{$pay_method_name}</div></li>
	</ul>
	<a class="wx" href="javascript:callpay()">微信支付</a>
</div>

{include file="footer.html"}
<script>
//调用微信JS api 支付
function jsApiCall(){
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		{$data},
		function(res){
			WeixinJSBridge.log(res.err_msg);
			if(res.err_msg=='get_brand_wcpay_request:ok'){
				var pay_method_name = '{$pay_method_name}';
				location.href = 'wap.php?app=cart&act=order_complete&order_sn={$order_sn}&total_price={$total_price}&pay_method_name='+pay_method_name.urlencode();
			}else{
				//location.href = 'wap.php?app=member&act=order&sign=';
				//alert('支付失败， 原因：\n'+res.err_desc);
				$('.cart-complete a.wx').html('重新支付');
			}
		}
	);
}

function callpay(){
	if (typeof WeixinJSBridge == "undefined"){
		if( document.addEventListener ){
			document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		}else if (document.attachEvent){
			document.attachEvent('WeixinJSBridgeReady', jsApiCall);
			document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		}
	}else{
		jsApiCall();
	}
}

$(function(){
	callpay();
});
</script>